Ignore `panic` configuration for test/bench profiles
authorAlex Crichton <alex@alexcrichton.com>
Thu, 6 Oct 2016 22:32:15 +0000 (15:32 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 2 Nov 2016 16:12:30 +0000 (09:12 -0700)
Both of these profiles link to libtest, so it's invalid to configure them with
`panic="abort"`. To prevent confusing errors just ignore the configuration for
now.

Closes #3166

src/cargo/ops/cargo_compile.rs
src/cargo/util/toml.rs
tests/test.rs

index 5a9513f94ccb38a2842e4877be6cc0910a76085f..324c528bf70344e042bcd1979f0b604dc309ebe5 100644 (file)
@@ -245,7 +245,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>,
         let _p = profile::start("compiling");
         let mut build_config = try!(scrape_build_config(config, jobs, target));
         build_config.release = release;
-        build_config.test = mode == CompileMode::Test;
+        build_config.test = mode == CompileMode::Test || mode == CompileMode::Bench;
         build_config.json_errors = message_format == MessageFormat::Json;
         if let CompileMode::Doc { deps } = mode {
             build_config.doc_all = deps;
index 4686eb9a29dcdc4116f29d6182ee1480bc74c1a7..bc72b5ee99bce26324b2ee11f64a01b82b6343d7 100644 (file)
@@ -1239,6 +1239,10 @@ fn build_profiles(profiles: &Option<TomlProfiles>) -> Profiles {
                    profiles.and_then(|p| p.doc.as_ref())),
         custom_build: Profile::default_custom_build(),
     };
+    // The test/bench targets cannot have panic=abort because they'll all get
+    // compiled with --test which requires the unwind runtime currently
+    profiles.test.panic = None;
+    profiles.bench.panic = None;
     profiles.test_deps.panic = None;
     profiles.bench_deps.panic = None;
     return profiles;
index 69f22e701a4cb96dfb2daa5cd551001303862aa8..5bc9d8e1bb7873da7641bf0a02d2e38cfbcd8b9f 100644 (file)
@@ -2332,3 +2332,35 @@ fn pass_correct_cfgs_flags_to_rustdoc() {
 [DOCTEST] foo
 [RUNNING] `rustdoc --test [..]feature_a[..]`"));
 }
+
+#[test]
+fn test_release_ignore_panic() {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "foo"
+            version = "0.0.1"
+            authors = []
+
+            [dependencies]
+            a = { path = "a" }
+
+            [profile.test]
+            panic = 'abort'
+            [profile.release]
+            panic = 'abort'
+        "#)
+        .file("src/lib.rs", "extern crate a;")
+        .file("a/Cargo.toml", r#"
+            [package]
+            name = "a"
+            version = "0.0.1"
+            authors = []
+        "#)
+        .file("a/src/lib.rs", "");
+    p.build();
+    println!("test");
+    assert_that(p.cargo("test").arg("-v"), execs().with_status(0));
+    println!("bench");
+    assert_that(p.cargo("bench").arg("-v"), execs().with_status(0));
+}